package com.system.business.service.impl;

import com.system.business.been.IntervalPlanLst;
import com.system.business.repository.IntervalPlanLstRepository;
import com.system.business.service.IntervalPlanLstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 林
 */
@Service
public class IntervalPlanLstServiceImpl implements IntervalPlanLstService {
    @Autowired
    private IntervalPlanLstRepository intervalPlanLstRepository;
    @Override
    public boolean saveIntervalPlanLst(IntervalPlanLst intervalPlanLst) {
        IntervalPlanLst obj = intervalPlanLstRepository.save(intervalPlanLst);
        if(obj != null){
            return true;
        }
        return false;
    }

    @Override
    public boolean removeIntervalPlanLstById(int id) {
        if (intervalPlanLstRepository.existsById(id)) {
            intervalPlanLstRepository.deleteById(id);
            return true;
        }
        return false;
    }

    @Override
    public boolean modifyIntervalPlanLst(IntervalPlanLst intervalPlanLst) {
        IntervalPlanLst obj = intervalPlanLstRepository.save(intervalPlanLst);
        if(obj != null){
            return true;
        }
        return false;
    }

    @Override
    public IntervalPlanLst getIntervalPlanLstById(int id) {
        if (intervalPlanLstRepository.existsById(id)) {
            return intervalPlanLstRepository.getReferenceById(id);
        }
        return null;
    }

    @Override
    public List<IntervalPlanLst> listAllIntervalPlanLst() {
        return intervalPlanLstRepository.findAll();
    }

    @Override
    public List<IntervalPlanLst> findAllByIntervalPlanId(int intervalPlanId) {
        return intervalPlanLstRepository.findAllByIntervalPlanId(intervalPlanId);
    }
}
